package com.cn.action;

import com.cn.service.NewsService;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

public class NewsAction implements ActionInterface {
    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        NewsService ns = new NewsService();
        ServletContext application = request.getServletContext();
        application.setAttribute("news", ns.queryAll());
            return "index.jsp";
    }
}
